program Summator;

{$APPTYPE CONSOLE}

type
  Summato = class
    n: integer;
    procedure sum;virtual;
  end;
  SmartSummato = class(Summato)
    procedure sum;override;
  end;

procedure Summato.sum;
var
  i, sum: integer;
begin
  sum:=0;
  for i:=1 to n do
    sum:=sum+i;
  write(sum);
end;
procedure SmartSummato.sum;
begin
  write(((n*(n+1))/2):0:0);
end;

var
  S: summato;
  a: integer;

begin
  readln(a);
  S:=Summato.Create;
  S.n:=a;
  S.sum;
  writeln;
  S:=SmartSummato.Create;
  S.n:=a;
  S.sum;
  readln;
end.
 